/*     */ package com.zimbra.cs.dav.resource;
/*     */ 
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import com.zimbra.common.util.L10nUtil;
/*     */ import com.zimbra.common.util.L10nUtil.MsgKey;
/*     */ import com.zimbra.common.util.Log;
/*     */ import com.zimbra.common.util.ZimbraLog;
/*     */ import com.zimbra.cs.account.Account;
/*     */ import com.zimbra.cs.account.Provisioning;
/*     */ import com.zimbra.cs.account.Server;
/*     */ import com.zimbra.cs.dav.DavContext;
/*     */ import com.zimbra.cs.dav.DavElements;
/*     */ import com.zimbra.cs.dav.DavElements.CardDav;
/*     */ import com.zimbra.cs.dav.DavException;
/*     */ import com.zimbra.cs.dav.property.ResourceProperty;
/*     */ import com.zimbra.cs.mailbox.Folder;
/*     */ import com.zimbra.cs.mailbox.MailItem.Type;
/*     */ import com.zimbra.cs.mailbox.calendar.cache.CtagInfo;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Locale;
/*     */ import org.dom4j.Element;
/*     */ import org.dom4j.QName;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class AddressbookCollection
/*     */   extends Collection
/*     */ {
/*     */   private final String mCtag;
/*     */   
/*     */   public AddressbookCollection(DavContext ctxt, Folder f)
/*     */     throws DavException, ServiceException
/*     */   {
/*  43 */     super(ctxt, f);
/*  44 */     Account acct = f.getAccount();
/*  45 */     Locale lc = acct.getLocale();
/*  46 */     String description = L10nUtil.getMessage(L10nUtil.MsgKey.carddavAddressbookDescription, lc, new Object[] { acct.getAttr("displayName"), f.getName() });
/*  47 */     ResourceProperty rp = new ResourceProperty(DavElements.CardDav.E_ADDRESSBOOK_DESCRIPTION);
/*  48 */     rp.setMessageLocale(lc);
/*  49 */     rp.setStringValue(description);
/*  50 */     rp.setProtected(false);
/*  51 */     addProperty(rp);
/*  52 */     rp = new ResourceProperty(DavElements.CardDav.E_SUPPORTED_ADDRESS_DATA);
/*  53 */     Element vcard = rp.addChild(DavElements.CardDav.E_ADDRESS_DATA);
/*  54 */     vcard.addAttribute("content-type", "text/vcard");
/*  55 */     vcard.addAttribute("version", "3.0");
/*  56 */     rp.setProtected(true);
/*  57 */     addProperty(rp);
/*  58 */     long maxSize = Provisioning.getInstance().getLocalServer().getLongAttr("zimbraFileUploadMaxSize", -1L);
/*  59 */     if (maxSize > 0L) {
/*  60 */       rp = new ResourceProperty(DavElements.CardDav.E_MAX_RESOURCE_SIZE_ADDRESSBOOK);
/*  61 */       rp.setStringValue(Long.toString(maxSize));
/*  62 */       rp.setProtected(true);
/*  63 */       addProperty(rp);
/*     */     }
/*  65 */     if (f.getDefaultView() == MailItem.Type.CONTACT) {
/*  66 */       addResourceType(DavElements.CardDav.E_ADDRESSBOOK);
/*     */     }
/*  68 */     this.mCtag = CtagInfo.makeCtag(f);
/*  69 */     setProperty(DavElements.E_GETCTAG, this.mCtag);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*  74 */   private static QName[] SUPPORTED_REPORTS = { DavElements.CardDav.E_ADDRESSBOOK_MULTIGET, DavElements.CardDav.E_ADDRESSBOOK_QUERY, DavElements.E_ACL_PRINCIPAL_PROP_SET, DavElements.E_PRINCIPAL_MATCH, DavElements.E_PRINCIPAL_PROPERTY_SEARCH, DavElements.E_PRINCIPAL_SEARCH_PROPERTY_SET, DavElements.E_EXPAND_PROPERTY };
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   protected QName[] getSupportedReports()
/*     */   {
/*  86 */     return SUPPORTED_REPORTS;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public java.util.Collection<DavResource> getChildren(DavContext ctxt)
/*     */     throws DavException
/*     */   {
/*  94 */     ArrayList<DavResource> children = new ArrayList();
/*  95 */     java.util.Collection<DavResource> allChildren = super.getChildren(ctxt);
/*  96 */     for (DavResource child : allChildren) {
/*  97 */       if ((child.isCollection()) || ((child instanceof AddressObject))) {
/*  98 */         children.add(child);
/*     */       } else {
/* 100 */         ZimbraLog.dav.debug("Ignoring non-address resource %s (class %s) AddressbookCollection child", new Object[] { child.getUri(), child.getClass().getName() });
/*     */       }
/*     */     }
/*     */     
/* 104 */     return children;
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/dav/resource/AddressbookCollection.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */